Basic Geoprocessing Tools#
Geoprocessing refers to a set of tools used to analyze and modify geospatial data. These tools allow you to:
Perform spatial operations
Analyze spatial relationships between features
Create new datasets based on existing ones
In this section, we’ll explore several commonly used geoprocessing tools:
Buffering – creating zones around features at a specified distance
Clip – trimming one dataset using the shape of another
Dissolve – merging geometries based on a shared attribute
Import libraries#
import pandas as pd
import geopandas as gpd
import osmnx as ox
pandas (
pandas) — a powerful Python library for data analysis and manipulation. It provides easy-to-use data structures, such as DataFrame, which is ideal for working with tabular (non-spatial) data like CSV files, spreadsheets, or database tables.GeoPandas (
geopandas) — an extension ofpandasthat makes working with geospatial data easy. It builds on the familiarDataFramestructure and adds support for spatial operations, geometry columns, and reading/writing spatial file formats like Shapefile, GeoJSON, and GeoPackage.
1. Buffering#
Buffering creates an area around geometric objects at a specified distance.
It’s useful for identifying zones of influence — for example, areas around bus stops, roads, or buildings.
A buffer zone is simply the area surrounding a geometry (point, line, or polygon) within a given distance. Buffers are commonly used to highlight nearby surroundings or define areas of impact.
Important note about coordinate systems:
If your data is in a geographic CRS (latitude/longitude), the buffer distance is interpreted in degrees, not meters.
To create realistic distance-based buffers (e.g., 500 meters), you should first reproject your data into a projected CRS (like UTM), where the units are in meters.
Let’s create a 500-meter buffer around kindergartens in Leopoldstadt district in Vienna
tags = {'amenity': 'kindergarten'}
kindergartens = ox.features_from_place('Leopoldstadt, Vienna', tags)
Explore it on a map
kindergartens.explore(tiles='cartodbpositron')
Before running the buffer tool, reproject your data to a projected CRS so distances are in meters. Let’s reproject it to the appropriate UTM zone for the study area.
kindergartens_utm = kindergartens.to_crs(kindergartens.estimate_utm_crs())
#create a buffer geometries and save it to "buffer_geometry" field
kindergartens_utm['buffer_geometry'] = kindergartens_utm.buffer(500)
#Create a GeoDataFrame based on the buffer_geometry
kindergartens_buffer = gpd.GeoDataFrame(kindergartens_utm, geometry='buffer_geometry', crs=kindergartens_utm.crs)
#Explore it on a map
kindergartens_buffer.explore(tiles='cartodbpositron')
2. Dissolve#
The dissolve operation merges geometries based on shared values in a specified attribute column.
It’s commonly used to combine adjacent features that belong to the same category — for example, merging individual districts into a single administrative region.
When you dissolve features, all geometries with the same value in the chosen column are grouped and combined into one. This reduces the number of features and can simplify your dataset for higher-level analysis or visualization.
Typical use cases include:
Combining neighborhoods into boroughs
Merging land parcels by owner
Aggregating zones by land use type
You can also aggregate attribute data (e.g., sum or mean) while dissolving, making it a powerful tool for both geometry and attribute-level simplification.
Our use case: we’ll take the kindergarten buffers from the kindergartens_buffer layer and dissolve them (no grouping key) to get a single polygon that shows the area of the district covered by kindergartens.
kindergartens_coverage = kindergartens_buffer.dissolve()
kindergartens_coverage.explore(tiles='cartodbpositron')
3. Clip#
The clip operation is used to extract portions of geometries that fall within a specified boundary.
It’s similar to using a cookie cutter — you “cut out” the parts of one layer that lie within the shape of another.
For example, you might clip a layer of roads or land cover to the boundary of a specific region or administrative unit. This helps limit your data to just the area of interest, making maps and analysis more focused and efficient.
Clipping is especially useful when working with large datasets and you only need to analyze a specific geographic subset.
Both layers should be in the same coordinate reference system before performing a clip
Now let’s show all buildings within the district that fall inside the 500-m kindergarten coverage zone.
#export buildings from OSM
buildings = ox.features_from_place('Leopoldstadt, Vienna', {'building': True} )
#reproject buildings to the same crs as kindergartens_coverage
buildings_utm = buildings.to_crs(kindergartens_coverage.crs)
#clip buildings
clipped_buildings = buildings_utm.clip(kindergartens_coverage)
#explore
clipped_buildings.explore(tiles='cartodbpositron')